<extend name="Public/main" />

<block name="style">
	<script type="text/javascript">
		var catid = "12";
	</script>
	<style type="text/css">
		.col-auto {
			overflow: hidden;
			_zoom: 1;
			_float: left;
			border: 1px solid #c2d1d8;
		}
		.col-right {
			float: right;
			width: 210px;
			overflow: hidden;
			margin-left: 6px;
			border: 1px solid #c2d1d8;
		}

		body fieldset {
			border: 1px solid #D8D8D8;
			padding: 10px;
			background-color: #FFF;
		}
		body fieldset legend {
			background-color: #F9F9F9;
			border: 1px solid #D8D8D8;
			font-weight: 700;
			padding: 3px 8px;
		}
		.content_attr {
			border: 1px solid #CCC;
			padding: 5px 8px;
			background: #FFC;
			margin-top: 6px
		}
		.list-dot{ padding-bottom:10px}
		.list-dot li,.list-dot-othors li{padding:5px 0; border-bottom:1px dotted #c6dde0; font-family:"宋体"; color:#bbb; position:relative;_height:22px}
		.list-dot li span,.list-dot-othors li span{color:#004499}
		.list-dot li a.close span,.list-dot-othors li a.close span{display:none}
		.list-dot li a.close,.list-dot-othors li a.close{ background: url("__STATIC__/images/cross.png") no-repeat left 3px; display:block; width:16px; height:16px;position: absolute;outline:none;right:5px; bottom:5px}
		.list-dot li a.close:hover,.list-dot-othors li a.close:hover{background-position: left -46px}
		.list-dot-othors li{float:left;width:24%;overflow:hidden;}
	</style>
</block>

<block name="body">
<link rel="stylesheet" type="text/css" href="__ROOT__/Public/webuploader/webuploader.css">
	
	<script type="text/javascript" src="__ROOT__/Public/webuploader/webuploader.js"></script>
<div id="uploader" class="wu-example">
    <!--用来存放文件信息-->
    <div id="thelist" class="uploader-list"></div>
    <div class="btns">
        <div id="picker">选择文件</div>
        <button id="ctlBtn" class="btn btn-default">开始上传</button>
    </div>
</div>

<script type="text/javascript">
// 图片上传demo
jQuery(function() {
    var $ = jQuery,
        $list = $('#picker'),
        // 优化retina, 在retina下这个值是2
        ratio = window.devicePixelRatio || 1,

        // 缩略图大小
        thumbnailWidth = 100 * ratio,
        thumbnailHeight = 100 * ratio,

        // Web Uploader实例
        uploader;

    // 初始化Web Uploader
    uploader = WebUploader.create({

        // 自动上传。
        auto: true,

        // swf文件路径
        swf: '__ROOT__/Public/webuploader/js/Uploader.swf',

        // 文件接收服务端。
        server: 'http://webuploader.duapp.com/server/fileupload.php',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker',

        // 只允许选择文件，可选。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });

    // 当有文件添加进来的时候
    uploader.on( 'fileQueued', function( file ) {
        var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail">' +
                    '<img>' +
                    '<div class="info">' + file.name + '</div>' +
                '</div>'
                ),
            $img = $li.find('img');

        $list.append( $li );

        // 创建缩略图
        uploader.makeThumb( file, function( error, src ) {
            if ( error ) {
                $img.replaceWith('<span>不能预览</span>');
                return;
            }

            $img.attr( 'src', src );
        }, thumbnailWidth, thumbnailHeight );
    });

    // 文件上传过程中创建进度条实时显示。
    uploader.on( 'uploadProgress', function( file, percentage ) {
        var $li = $( '#'+file.id ),
            $percent = $li.find('.progress span');

        // 避免重复创建
        if ( !$percent.length ) {
            $percent = $('<p class="progress"><span></span></p>')
                    .appendTo( $li )
                    .find('span');
        }

        $percent.css( 'width', percentage * 100 + '%' );
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on( 'uploadSuccess', function( file ) {
        $( '#'+file.id ).addClass('upload-state-done');
    });

    // 文件上传失败，现实上传出错。
    uploader.on( 'uploadError', function( file ) {
        var $li = $( '#'+file.id ),
            $error = $li.find('div.error');

        // 避免重复创建
        if ( !$error.length ) {
            $error = $('<div class="error"></div>').appendTo( $li );
        }

        $error.text('上传失败');
    });

    // 完成上传完了，成功或者失败，先删除进度条。
    uploader.on( 'uploadComplete', function( file ) {
        $( '#'+file.id ).find('.progress').remove();
    });
});


</script>

	<div class="wrap J_check_wrap">
		<div class="nav">
			<ul class="cc">
				<li ><a href="{:U('Recipients/index')}">待支助人列表</a></li>
				<li class="current"><a target="_self" href="{:U('Recipients/add')}">添加待支助人</a></li>
				<li><a target="_self" href="{:U('Recipients/pushbyexcel',array('term'=>$term['term_id']))}">Excel导入</a></li
			</ul>
		</div>
		<form name="myform" id="myform" action="#" method="post" class="J_ajaxForms" enctype="multipart/form-data">
			<div class="col-right">
				<div class="table_full">
					<table width="100%">
						<tr>
							<td><b>图相</b></td>
						</tr>
						<tr>
							<td>
								<div  style="text-align: center;"><input type='hidden' name='thumb_ico' id='thumb' value='{$db.thumb_ico}'>
									<a href='javascript:void(0);' onclick="flashupload('thumb_images', '附件上传', 'thumb', thumb_images, '1,jpg|jpeg|gif|png|bmp,1,,,1', 'content', '12', 'b6ba209759e147124653ac77362ef2bd');
											return false;">
										<img src='{$db.thumb_ico}' id='thumb_preview' width='135' height='113' style='cursor:hand' /></a>
									<input type="button" class="btn" onclick="crop_cut_thumb($('#thumb').val());return false;" value="裁减图片"> 
									<input type="button"  class="btn" onclick="$('#thumb_preview').attr('src', '__STATIC__/images/icon/upload-pic.png');
											$('#thumb').val('');
											return false;" value="取消图片">
								</div>
							</td>
						</tr>

					
					</table>
				</div>
			</div>
			<style type="text/css">
				table tr td span{
					width: 50px;display: inline-block;text-align: right;padding-right: 10px;
				}
			</style>
			<div class="col-auto">
				<div class="h_a">文章内容</div>
				<div class="table_full">
				<table width="100%">
				<tr>
					<th width="80"></th>
					<input type="hidden" name="rid" value="{$db.rid}">
					<td><span>姓名</span><input type="text" name="name" value="{$db.name}"></td>
					<td><span>性别</span>	<select name="age">
										<option value="1" <?php if($db['sex'] == 1){echo "selected='selected'";} ?> >男</option>
										<option value="2"<?php if($db['sex'] == 2){echo "selected='selected'";} ?> >女</option>
									</select></td>
					<td><span>年级</span><input type="text" name="grade" value="{$db.grade}"></td>
					<td><span>民族</span><input type="text"	name = "nation" value="{$db.nation}"></td>
					
					
				</tr>
				<tr>
				<th></th>
					<td><span>学校名</span><input type="text" name="school_name" value="{$db.school_name}"></td>
					<td><span>班主任</span><input type="text" name="class_teacher_name" value="{$db.class_teacher_name}"></td>
					<td><span>班主电话</span><input type="text" name="class_teacher_phone" value="{$db.class_teacher_phone}"></td>
				</tr>
				<tr>
					<th></th>
					<td><span>父亲名字</span><input type="text" name="father_name" value="{$db.father_name}"></td>
					<td><span>父亲年龄</span><input type="text" name="father_age" value="{$db.father_age}"></td>
					<td><span>父亲职业</span><input type="text" name="father_vocation" value="{$db.father_vocation}"></td>
					<td><span>母亲名字</span><input type="text" name="mather_name" value="{$db.mather_name}"></td>
					<td><span>母亲年龄</span><input type="text" name="mather_age" value="{$db.mather_age}"></td>
					<td><span>母亲职业</span><input type="text" name="mather_vocation" value="{$db.mather_vocation}"></td>

				</tr>
				<tr>
					<th></th>
					<td><span>需要捐助金额</span><input type="text" name="need_money" value="{$db.need_money}"></td>
		
					<td><span>需要开始时间</span><input class="input length_3 J_datetime " type="text" name="start_time" value="{$db.start_time}"></td>
					<td><span>需要结束时间</span><input class="input length_3 J_datetime " type="text" name="end_time" value="{$db.end_time}"></td>
					

				</tr>
				</table>
					<table width="100%">
					<tr>
							<th width="80">所属种类</th>
							<td>
								<select name="love_type" id="">
								<option value="1" <?php if($db['love_type']==1){echo "selected = 'selected'";} ?> >春草行动</option>
								<option value="2" <?php if($db['love_type']==2){echo "selected = 'selected'";} ?> >春风行动</option>

							</select>
							</td>
							
							
						</tr>
						<tr>
							<th width="80">家庭住址</th>
							<td><input type='text' name='family_address'   style='width:280px'   class='input' value="{$db.family_address}" placeholder=''></td>
						</tr>
						<tr>
							<th width="80">家庭电话</th>
							<td><input type='text' name='family_phone_number'   style='width:280px' value="{$db.family_phone_number}"    class='input' placeholder=''></td>
						</tr>
						<tr>
						<th width="80">家庭年收入</th>
							<td><input type='text' name='annual_earnings'   style='width:280px' value="{$db.annual_earnings}"   class='input' placeholder=''></td>
						</tr>
						<tr>
							<th width="80">学校提供的家庭信息 </th>
							<td><textarea name='family_info_by_school' id='description'  style='width:98%;height:70px;'>{$db.family_info_by_school}</textarea> </td>
						</tr>
						<th width="80">信息确认人</th>
							<td><input type='text' name='check_people'   style='width:280px' value="{$db.check_people}"   class='input' placeholder=''></td>
						</tr>
						<tr>
							<th width="80">确认人提供的信息</th>
							<td><textarea name='family_info_by_checkpeople' id='description' style='width:98%;height:70px;'>{$db.family_info_by_checkpeople}</textarea> </td>
						</tr>
						<tr>
							<th width="80">协会捐助意见</th>
							<td><input type="text" name="donor_opinion" value="{$db.donor_opinion}"> </td>
						</tr>
						<tr>
							<th width="80">资料确认时间</th>
							<td><input type="text" name="sign_data_time" class="input length_3 J_datetime "  value="{$db.sign_data_time}"> </td>
						</tr>

						</tbody>
					</table>
				</div>
			</div>
			<div class="" style="z-index:999;text-align: center;margin-top:20px;">
				<div class="btn_wrap_pd">
					<input value="56" type="hidden" name="id">
					<input type="hidden" name="catid" value="12" />
					<input type="hidden" name="ajax" value="1" />
					<button class="btn btn_submit J_ajax_submit_btn"type="submit">提交</button>
					<button class="btn J_ajax_close_btn"type="submit">关闭</button>
				</div>
			</div>
		</form>
	</div>
</block>

<block name="script">
	
	<script type="text/javascript" src="__STATIC__/js/content_addtop.js{$js_debug}"></script>
	<script type="text/javascript">
									//编辑器路径定义
									var editorURL = GV.DIMAUB;
	</script>

	<script type="text/javascript"  src="__STATIC__/js/ueditor/editor_config.js"></script>
	<script type="text/javascript"  src="__STATIC__/js/ueditor/editor_all_min.js"></script>

	<script type="text/javascript">

									var editorcontent;
									UE.commands['attachments'] = {
										execCommand: function(cmd) {
											flashupload('flashupload', '附件上传', 'content', ueAttachment, '10,,1,,,0', 'Contents', '12', 'd909680d11bb7090136c35b9b9d4e66d');
										},
										queryCommandState: function() {
											return this.highlight ? -1 : 0;
										}
									};

									$(function() {
										//setInterval(function(){public_lock_renewal();}, 10000);
										$(".J_ajax_close_btn").on('click', function(e) {
											e.preventDefault();
											Wind.use("artDialog", function() {
												art.dialog({
													id: "question",
													icon: "question",
													fixed: true,
													lock: true,
													background: "#CCCCCC",
													opacity: 0,
													content: "您确定需要关闭当前页面嘛？",
													ok: function() {
														setCookie("refersh_time", 1);
														window.close();
														return true;
													}
												});
											});
										});
										/////---------------------
										Wind.use('validate', 'ajaxForm', 'artDialog', function() {
											//javascript

											//编辑器
											editorcontent = new baidu.editor.ui.Editor();
											editorcontent.render('content');
											try {
												editorcontent.sync();
											} catch (err) {
											}
											;
											//增加编辑器验证规则
											jQuery.validator.addMethod('editorcontent', function() {
												try {
													editorcontent.sync();
												} catch (err) {
												}
												;
												return editorcontent.hasContents();
											});
											var form = $('form.J_ajaxForms');
											//ie处理placeholder提交问题
											if ($.browser.msie) {
												form.find('[placeholder]').each(function() {
													var input = $(this);
													if (input.val() == input.attr('placeholder')) {
														input.val('');
													}
												});
											}
											//表单验证开始
											form.validate({
												//是否在获取焦点时验证
												onfocusout: false,
												//是否在敲击键盘时验证
												onkeyup: false,
												//当鼠标掉级时验证
												onclick: false,
												//验证错误
												showErrors: function(errorMap, errorArr) {
													//errorMap {'name':'错误信息'}
													//errorArr [{'message':'错误信息',element:({})}]
													try {
														$(errorArr[0].element).focus();
														art.dialog({
															id: 'error',
															icon: 'error',
															lock: true,
															fixed: true,
															background: "#CCCCCC",
															opacity: 0,
															content: errorArr[0].message,
															cancelVal: '确定',
															cancel: function() {
																$(errorArr[0].element).focus();
															}
														});
													} catch (err) {
													}
												},
												//验证规则
												rules: {'post[post_title]': {required: 1}, 'post[post_content]': {editorcontent: true}},
												//验证未通过提示消息
												messages: {'post[post_title]': {required: '请输入标题'}, 'post[post_content]': {editorcontent: '内容不能为空'}},
												//给未通过验证的元素加效果,闪烁等
												highlight: false,
												//是否在获取焦点时验证
												onfocusout: false,
														//验证通过，提交表单
														submitHandler: function(forms) {
															$(forms).ajaxSubmit({
																url: form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
																dataType: 'json',
																beforeSubmit: function(arr, $form, options) {

																},
																success: function(data, statusText, xhr, $form) {
																	if (data.status) {
																		setCookie("refersh_time", 1);
																		//添加成功
																		Wind.use("artDialog", function() {
																			art.dialog({
																				id: "succeed",
																				icon: "succeed",
																				fixed: true,
																				lock: true,
																				background: "#CCCCCC",
																				opacity: 0,
																				content: data.info,
																				button: [
																					{
																						name: '继续修改？',
																						callback: function() {
																							reloadPage(window);
																							return true;
																						},
																						focus: true
																					}, {
																						name: '返回列表页',
																						callback: function() {
																							location = '__URL__';
																							return true;
																						}
																					}
																				]
																			});
																		});
																	} else {
																		isalert(data.info);
																	}
																}
															});
														}
											});
										});
										////-------------------------
									});
	</script>	
</block>
